﻿using System;

namespace CollegeSim.Domain.Entities
{
    // Author: Ryan Redburn
    // Project: CollegeSim
    // Date: 5/6/2014

    /// <summary>
    /// Class used to represent a school year. Contains properties.
    /// </summary>
    public class SchoolYear
    {
        #region [ Fields ]

        private DateTime _start;
        private DateTime _end;

        #endregion

        #region [ Properties ]

        // SchoolYearID
        // Set by BD
        public int SchoolYearID { get; set; }

        /// <summary>
        /// Represents the beginning of the school year
        /// </summary>
        public DateTime Start
        {
            get { return _start; }
            set
            {
                if (_end == new DateTime(00001, 1, 1) || value < _end)
                {
                    _start = value;
                }
                else
                {
                    throw new ArgumentOutOfRangeException("value", "The start date cannot occur after the end date.");
                }
            }
        }

        /// <summary>
        /// Represents the beginning of the school year
        /// </summary>
        public DateTime End
        {
            get { return _end; }
            set
            {
                if (_start == new DateTime(00001, 1, 1) || value > _start)
                {
                    _end = value;
                }
                else
                {
                    throw new ArgumentOutOfRangeException("value", "The end date cannot occur before the start date.");
                }
            }
        }

        #endregion

        #region [ Constructors ]

        // Initialize SchoolYearID
        public SchoolYear()
        {
            SchoolYearID = 0;
        }

        #endregion
    }
}
